package cn.gson.crm.controller.employee;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.EmpDao;
import cn.gson.crm.model.entity.Employee;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 重置密码
 */
@WebServlet("/employee/changepassword")
public class EmployeeChangePasswordServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private EmpDao empDao=new EmpDao();

	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		Employee employee=empDao.getUserById(id);
		employee.setEmpPassword("1");
		boolean result=empDao.updateEmp(employee, id);
		if(!result){
			errorForward("重置失败", "employee/emp_manage.jsp");
			return;
		}
		redirect("employee");
	}

}
